package router

import (
	beego "github.com/beego/beego/v2/server/web"
	web "ksd-social-api/modules/note/controller"
)

type NoteRouter struct {
}

/**
 * @author feige
 * @date 2023-10-14
 * @version 1.0
 * @desc 需要登录路由
 */
func (router *NoteRouter) InitRouter() beego.LinkNamespace {
	// 用户中心--子命名空间
	namespace := beego.NSNamespace("/cnote",
		// 小册编辑
		beego.NSCtrlPost("deletecache/:noteId", (*web.NoteController).DeleteNoteCache),
		// 保存小册
		beego.NSCtrlPost("saveupdate", (*web.NoteController).SaveUpdateNoteVideo),
		beego.NSCtrlPost("saveCopy/:noteId", (*web.NoteController).SaveCopy),
		// 小册编辑
		beego.NSCtrlPost("update/video", (*web.NoteController).UpdateNoteVideo),
		beego.NSCtrlPost("update/videoid", (*web.NoteController).UpdateNoteVideoId),
		// 小册点赞
		beego.NSCtrlPost("like/:noteId", (*web.NoteController).LikeNote),
		// 小册取消点赞
		beego.NSCtrlPost("unLike/:noteId", (*web.NoteController).UnLikeNote),
		// 小册收藏
		beego.NSCtrlPost("fav/:noteId", (*web.NoteController).FavNote),
		// 小册取消收藏
		beego.NSCtrlPost("unFav/:noteId", (*web.NoteController).UnFavNote),

		// 保存评论
		beego.NSCtrlPost("saveComment", (*web.NoteCommentController).SaveComment),
		// 删除评论
		beego.NSCtrlPost("delComment", (*web.NoteCommentController).DelComment),
		// 保存回复
		beego.NSCtrlPost("saveCommentReply", (*web.NoteCommentReplyController).SaveComment),
		// 删除回复
		beego.NSCtrlPost("delCommentReply", (*web.NoteCommentReplyController).DelComment),

		// 收藏，取消收藏
		beego.NSCtrlPost("fav/savecancel", (*web.NoteUserFavController).SaveCancelNoteUserFav),
		// 删除收藏
		beego.NSCtrlPost("fav/del", (*web.NoteUserFavController).DelNoteUserFav),

		// 点赞，取消点赞
		beego.NSCtrlPost("like/savecancel", (*web.NoteUserLikeController).SaveCancelNoteUserLike),
		// 删除点赞
		beego.NSCtrlPost("like/del", (*web.NoteUserLikeController).DelNoteUserLike),

		// 小册兑换码
		beego.NSCtrlPost("code/dh", (*web.NoteCodeController).DuihuanNote),
		// 学习币兑换
		beego.NSCtrlPost("coin/dh", (*web.NoteCodeController).DuihuanCoinNote),
		// 章处理
		beego.NSCtrlPost("chapter/lesson/userrecords", (*web.NoteChapterController).SaveUserChapterLessonRecords),
		beego.NSCtrlPost("chapter/list/:id", (*web.NoteChapterController).FindChapterLessons),
		beego.NSCtrlPost("chapter/get/:id/:noteId", (*web.NoteChapterController).GetById),
		beego.NSCtrlPost("chapter/getvalidator", (*web.NoteChapterController).GetByIdValidator),
		beego.NSCtrlPost("chapter/copy/:id/:noteId", (*web.NoteChapterController).CopyData),
		beego.NSCtrlPost("chapter/remove", (*web.NoteChapterController).RemoveByID),
		beego.NSCtrlPost("chapter/status", (*web.NoteChapterController).UpdateStatus),
		beego.NSCtrlPost("chapter/save", (*web.NoteChapterController).SaveChapter),
		beego.NSCtrlPost("chapter/update/content", (*web.NoteChapterController).UpdateContent),
		// 节处理
		beego.NSCtrlPost("lesson/get/:id/:noteId", (*web.NoteLessonController).GetById),
		beego.NSCtrlPost("lesson/getvalidator", (*web.NoteLessonController).GetByIdValidator),
		beego.NSCtrlPost("lesson/copy/:id/:noteId", (*web.NoteLessonController).CopyData),
		beego.NSCtrlPost("lesson/remove", (*web.NoteLessonController).RemoveByID),
		beego.NSCtrlPost("lesson/status", (*web.NoteLessonController).UpdateStatus),
		beego.NSCtrlPost("lesson/save", (*web.NoteLessonController).SaveLesson),
		beego.NSCtrlPost("lesson/update/content", (*web.NoteLessonController).UpdateContent),

		// 课程点播记录学习
		beego.NSCtrlPost("user/records", (*web.NoteStudyUserRecordsController).SaveNoteStudyUserRecords),
	)
	return namespace
}

/**
 * @author feige
 * @date 2023-10-14
 * @version 1.0
 * @desc  不需要登录
 */
func (router *NoteRouter) InitNoLoginRouter() beego.LinkNamespace {
	// 用户中心--子命名空间
	namespace := beego.NSNamespace("/cnote",
		// 查看小册分类明细
		beego.NSCtrlPost("count/all/:channelId", (*web.NoteController).CountNoteAll),
		beego.NSCtrlPost("category/list/:channelId", (*web.NoteCategoryController).FindCategories),
		beego.NSCtrlPost("category/listall", (*web.NoteCategoryController).FindCategoriesAll),
		beego.NSCtrlPost("prevnext/:noteId", (*web.NoteController).FindNotePrevNext),
		// 查看推荐小册
		beego.NSCtrlPost("push/list", (*web.NoteController).FindPushNoteListAndPage),
		// 查看小册的明细
		beego.NSCtrlPost("detail/:id", (*web.NoteController).GetDetail),
		beego.NSCtrlPost("detailall/:id", (*web.NoteController).GetDetailAll),
		beego.NSCtrlPost("chapter/liststatus/:id", (*web.NoteChapterController).FindChapterLessonsStatus),
		// 查看小册的明细
		beego.NSCtrlPost("list", (*web.NoteController).FindNoteListAndPage),
		// 评论列表查询
		beego.NSCtrlPost("pageComment", (*web.NoteCommentController).FindCommentList),
		// 回复列表查询
		beego.NSCtrlPost("pageCommentRepley", (*web.NoteCommentReplyController).FindCommentList),
		beego.NSCtrlPost("lesson/getnovalidator", (*web.NoteLessonController).GetByIdValidator),
		beego.NSCtrlPost("chapter/getnovalidator", (*web.NoteChapterController).GetByIdValidator),
	)
	return namespace
}

/**
 * @author feige
 * @date 2023-10-14
 * @version 1.0
 */
func (router *NoteRouter) InitAdminRouter() beego.LinkNamespace {
	namespace := beego.NSNamespace("/adminnote",
		// 查询列表
		beego.NSCtrlPost("/list", (*web.AdminNoteController).FindNotes),
		// 修改状态
		beego.NSCtrlPost("/update/statusmany", (*web.AdminNoteController).UpdateFieldById),
		// 修改状态
		beego.NSCtrlPost("/update/status", (*web.AdminNoteController).UpdateFieldById2),
		// 保存兑换码
		beego.NSCtrlPost("/code/saveupdate", (*web.AdminNoteController).SaveUpdateCodes),
		// 修改兑换码
		beego.NSCtrlPost("/code/update/status", (*web.AdminNoteController).UpdateFieldByCodeId),

		// 查询列表
		beego.NSCtrlPost("/category/list", (*web.AdminNoteCategoryController).FindCategoriesAll),
		// 修改状态
		beego.NSCtrlPost("/category/update/status", (*web.AdminNoteCategoryController).UpdateFieldById),
		// 保存兑换码
		beego.NSCtrlPost("/category/saveupdate", (*web.AdminNoteCategoryController).SaveUpdateNoteCategory),
		// 删除
		beego.NSCtrlPost("/category/del/:id", (*web.AdminNoteCategoryController).DelById),
		// 复制
		beego.NSCtrlPost("/category/copy/:id", (*web.AdminNoteCategoryController).CopyData),

		// 查看兑换码
		beego.NSCtrlPost("/code/list", (*web.AdminNoteController).FindCodes),
		// 批量兑换
		beego.NSCtrlPost("/batch/users", (*web.AdminNoteController).BatchSaveOrders),
		// 删除兑换码
		beego.NSCtrlPost("/code/del/:id", (*web.AdminNoteController).DelCodeById),
		// 删除
		beego.NSCtrlPost("/del/:id", (*web.AdminNoteController).DelById),
		// 复制
		beego.NSCtrlPost("/copy/:id", (*web.AdminNoteController).CopyData),
	)
	return namespace
}
